local skill = fk.CreateSkill{
  name = "action__liangleichadao_skill",
}

Fk:loadTranslationTable{
  ["action__liangleichadao"] = "两肋插刀",
  ["action__liangleichadao_skill"] = "两肋插刀",
  [":action__liangleichadao"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：你 <br /><b>效果</b>：本轮内随机两名没有此效果的角色受到的伤害和体力流失改为对方承担。（不可响应）",
  ["#action__liangleichadao_skill"] = "令本轮内随机两名没有此效果的角色受到的伤害和体力流失改为对方承担",
  ["@action__llcd_look-round"] = "两肋插刀",
}


skill:addEffect("cardskill", {
  mute = true,
  name = "action__liangleichadao",
  prompt = "#action__liangleichadao_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    cardUseEvent.disresponsiveList = table.simpleClone(Fk:currentRoom().players)
    if not cardUseEvent.tos or #cardUseEvent.tos == 0 then
      cardUseEvent.tos = { cardUseEvent.from }
    end
  end,
  on_effect = function(self, room, effect)
    local canto = table.filter(room.alive_players, function(p) return p:getMark("action__liangleichadao-round") == 0 end)
    if #canto < 2 then return false end
    local to1 = table.random(table.filter(room.alive_players, function(p) return p:getMark("action__liangleichadao-round") == 0 end))
    local to2 = table.random(table.filter(room.alive_players, function(p) return p.id ~= to1.id and p:getMark("action__liangleichadao-round") == 0 end))
    room:setPlayerMark(to1,"action__liangleichadao-round", to2.id)
    room:setPlayerMark(to1,"@action__llcd_look-round", Fk:translate(to2.general))
    room:setPlayerMark(to2,"action__liangleichadao-round", to1.id)
    room:setPlayerMark(to2,"@action__llcd_look-round", Fk:translate(to1.general))
  end,
})

skill:addEffect(fk.DamageInflicted, {
  mute = true,
  global = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("action__liangleichadao-round") ~= 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to_damage = room:getPlayerById(player:getMark("action__liangleichadao-round"))
    data.to = to_damage
  end,
})

skill:addEffect(fk.PreHpLost, {
  mute = true,
  global = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("action__liangleichadao-round") ~= 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to_damage = room:getPlayerById(player:getMark("action__liangleichadao-round"))
    data.who = to_damage
  end,
})


return skill